﻿using System;
using System.Collections.Generic;
using System.Configuration;

namespace ZilLion.Core.Unities.Config
{
    public class DefaultAppConfigProvider : IAppConfigProvider
    {
        private static readonly IDictionary<string, string> _appSetting = new Dictionary<string, string>();

        /// <summary>
        /// </summary>
        public DefaultAppConfigProvider()
        {
            
                foreach (var appkey in ConfigurationManager.AppSettings.AllKeys)
                    _appSetting.Add(appkey.ToLower(), ConfigurationManager.AppSettings[appkey]);
           
        }

        public string GetAppSetting(string key)
        {
            return _appSetting.ContainsKey(key.ToLower()) ? _appSetting[key.ToLower()] : string.Empty;
        }


        public Action RefreshAction { get; set; }
        public Action<string, string> SaveAppSettingAction { get; set; }
    }
}